Skip to content

Conversation

@dcendents
Copy link
Contributor

With the current gitlab4j-api (4.19.0), when the jersey-media-json-binding is on the classpath, jersey will use jsonb (eclipse yasson) to deserialize the json response, because it implements the ForcedAutoDiscoverable interface and always gets registered with a higher priority.

https://github.com/eclipse-ee4j/jersey/blob/master/media/json-binding/src/main/java/org/glassfish/jersey/jsonb/internal/JsonBindingAutoDiscoverable.java

https://github.com/eclipse-ee4j/jersey/blob/9dbc693eaff403e4a1b285cac77361fd96b9b694/core-common/src/main/java/org/glassfish/jersey/internal/spi/ForcedAutoDiscoverable.java

To fix this, we need to register the JacksonFeature to force jersey to use jackson over json binding.

Context:

I use 2 plugins in jenkins: the gitlab-plugin which uses jersey directly and the gitlab-branch-source plugin that uses gitlab4j-api (packaged in the gitlab-api plugin).

Since gitlab-plugin has been updated to use a new jersey2-api plugin, I had strange ClassCastException with gitlab4j-api and jersey, to fix this I'm modifying the gitlab-api plugin to also use the jersey2-api plugin instead of packaging its own jersey libs. Because the jersey2-api plugin contains jersey-media-json-binding, it wasn't working until I made the changes to register JacksonFeature.

@jabby jabby merged commit e9e2a5b into gitlab4j:master Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants